<?php
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
require_once 'db_conn.php';
//测试：收集留言，显示出来
/*echo $_POST["username"]."</br>";
echo $_POST["sex"]."</br>";
echo $_POST["message"]."</br>";
echo $_POST["imgurl"]."</br>";*/
$username=$_POST["username"];
$sex=$_POST["sex"];
$message=$_POST["message"];
$imgurl=$_POST["imgurl"];
//写sql
$sql="insert into t_message(username,sex,message,imgurl) values('$username','$sex','$message','$imgurl')";
 $result=$db->query($sql);//执行数据
 if($result)
 {
     echo "<script language='javascript' type='text/javascript'>";
     echo "alert('留言成功');";
     echo "window.location.href='index.php';";
     echo "</script>";
     exit;
 }
 else
 {
     echo "<script language='javascript' type='text/javascript'>";
     echo "alert('留言失败');";
     echo "window.location.href='index.php';";
     echo "</script>";
     exit;
 }
 
 //判断留言是否成功
// header("Location:index.php");